(function () {
  let myChart = echarts.init(
    document.querySelector(".box:nth-of-type(2)")
  );
  let option = {
    dataset: [
      {
        source: [
          ["Product", "Sales", "Price", "Year"],
          ["美食", 123, 32, 2011],
          ["甜点饮品", 231, 14, 2011],
          ["超市便利", 235, 5, 2011],
          ["蔬菜水果", 341, 25, 2011],
          ["美团买药", 122, 29, 2011],
          ["美食", 143, 30, 2012],
          ["甜点饮品", 201, 19, 2012],
          ["超市便利", 255, 7, 2012],
          ["蔬菜水果", 241, 27, 2012],
          ["美团买药", 102, 34, 2012],
          ["美食", 153, 28, 2013],
          ["甜点饮品", 181, 21, 2013],
          ["超市便利", 395, 4, 2013],
          ["蔬菜水果", 281, 31, 2013],
          ["美团买药", 92, 39, 2013],
        ],
      },
      {
        transform: {
          type: "filter",
          config: { dimension: "Year", value: 2011 },
        },
      },
      {
        transform: {
          type: "filter",
          config: { dimension: "Year", value: 2012 },
        },
      },
      {
        transform: {
          type: "filter",
          config: { dimension: "Year", value: 2013 },
        },
      },
    ],
    series: [
      {
        type: "pie",
        radius: 50,
        center: ["50%", "25%"],
        datasetIndex: 1,
      },
      {
        type: "pie",
        radius: 50,
        center: ["50%", "50%"],
        datasetIndex: 2,
      },
      {
        type: "pie",
        radius: 50,
        center: ["50%", "75%"],
        datasetIndex: 3,
      },
    ],
    // Optional. Only for responsive layout:
    media: [
      {
        query: { minAspectRatio: 1 },
        option: {
          series: [
            { center: ["25%", "50%"] },
            { center: ["50%", "50%"] },
            { center: ["75%", "50%"] },
          ],
        },
      },
      {
        option: {
          series: [
            { center: ["50%", "25%"] },
            { center: ["50%", "50%"] },
            { center: ["50%", "75%"] },
          ],
        },
      },
    ],
  };
  //# 使用刚指定的配置项和数据显示图表
  myChart.setOption(option);

  window.addEventListener("resize", () => {
    myChart.resize();
  });
})();
